from django.contrib import admin
from .models import Cluster, Node, Instance, ResourceUsage

@admin.register(Cluster)
class ClusterAdmin(admin.ModelAdmin):
    list_display = ('name', 'created_by', 'created_at', 'updated_at')
    search_fields = ('name', 'description')
    list_filter = ('created_at', 'updated_at')

@admin.register(Node)
class NodeAdmin(admin.ModelAdmin):
    list_display = ('name', 'cluster', 'ip_address', 'status', 'cpu_cores', 'memory_gb', 'disk_gb')
    search_fields = ('name', 'ip_address')
    list_filter = ('status', 'cluster', 'created_at')

@admin.register(Instance)
class InstanceAdmin(admin.ModelAdmin):
    list_display = ('name', 'node', 'status', 'cpu_cores', 'memory_gb', 'disk_gb', 'created_by')
    search_fields = ('name',)
    list_filter = ('status', 'node', 'created_at')

@admin.register(ResourceUsage)
class ResourceUsageAdmin(admin.ModelAdmin):
    list_display = ('instance', 'cpu_usage', 'memory_usage', 'disk_usage', 'timestamp')
    list_filter = ('timestamp', 'instance')
    search_fields = ('instance__name',)
